<include file="Public:header" />
<!--主体内容-->
<!--左边-->
<div class="centent_box">
    <include file="Public:left" />
    <!--右边-->
    <div class="centent_right_box">
        <div class="centent_right rightCon">
            <div class="Mtitle">
                <ul id="ul_li">
                    <li data-bid="ordinaryPass" class="on"><span id="spanOld">普通密码修改</span></li>
                    <li data-bid="phonePass">
                        <b class="spansx"></b>
                        <span id="spanCode">手机动态码修改</span>
                    </li>
                </ul>
            </div>
            <form id="pass_form" action="{:U('Account/password')}" method="post">
            <div id="ordinaryPass" class="itemCon" style="display: block;">
                <ul class="formList">
                    <li>
                        <label><em class="red">*</em> 输入旧密码：</label>
                        <input type="password" class="inputStyle" id="oldPass" name="oldPass">
                    </li>
                    <li>
                        <label><em class="red">*</em> 输入新密码：</label>
                        <input type="password" class="inputStyle" id="newPass" name="newPass">
                    </li>
                    <li>
                        <label><em class="red">*</em> 新密码确认：</label>
                        <input type="password" class="inputStyle" id="newPass2" name="newPass1">
                    </li>
                    <li>
                        <label></label>
                        <input type="submit" class="btnStyle" value="确 定">
                    </li>
                </ul>
            </div>
            </form>

            <form id="pass1_form" action="{:U('Account/password')}" method="post">
            <div id="phonePass" class="itemCon" style="display: none;">
                <ul class="formList">
                    <li>
                        <label><em class="red">*</em> 输入手机号码：</label>
                        <input type="text" value="{$user.mobile}" name="mobile" class="inputStyle" readonly="true" id="mobile">
                        <input type="button" class="btnCss" value="获取验证码" onclick="getCode()" id="btnSend">
                    </li>
                    <li>
                        <label><em class="red">*</em> 手机验证码：</label>
                        <input type="text" class="inputStyle" name="code" id="code">
                    </li>
                    <li>
                        <label><em class="red">*</em> 输入新密码：</label>
                        <input type="password" class="inputStyle" name="newPass" id="newPwd">
                    </li>
                    <li>
                        <label><em class="red">*</em> 新密码确认：</label>
                        <input type="password" class="inputStyle" name="newPass1" id="newPwd1">
                    </li>
                    <li>
                        <label></label>
                        <input type="submit" class="btnStyle" value="确 定">
                    </li>
                </ul>
            </div>
            </form>

        </div>
    </div>
</div>
<script src="__S__/js/jquery.validate.js"></script>
<script type="text/javascript">
    $(function(){
        $("#pass_form").validate({
            rules: {
                oldPass: {
                    required: true,
                    minlength: 6
                },
                newPass: {
                    required: true,
                    minlength: 6
                },
                newPass1: {
                    required: true,
                    minlength: 6,
                    equalTo: "#newPass"
                }
            },
            messages: {
                oldPass: {
                    required: "请输入旧密码",
                    minlength: "旧密码要6位字以上"
                },
                newPass: {
                    required: "请输入新密码",
                    minlength: "密码长度不能小于6位字符"
                },
                newPass1: {
                    required: "请输入确认密码",
                    minlength: "密码长度不能小于6位字符",
                    equalTo: "两次密码输入不一致"
                }
            }
        });

        $("#pass1_form").validate({
            rules: {
                code: {
                    required: true,
                    minlength: 6
                },
                newPass: {
                    required: true,
                    minlength: 6
                },
                newPass1: {
                    required: true,
                    minlength: 6,
                    equalTo: "#newPwd"
                }
            },
            messages: {
                code: {
                    required: "请输入验证码",
                    minlength: "验证码5位以上"
                },
                newPass: {
                    required: "请输入新密码",
                    minlength: "密码长度不能小于6位字符"
                },
                newPass1: {
                    required: "请输入确认密码",
                    minlength: "密码长度不能小于6位字符",
                    equalTo: "两次密码输入不一致"
                }
            }
        });

        $("#ul_li li").click(function(){
            var v = $(this).attr("data-bid");
            $("#ordinaryPass,#phonePass").hide();
            $("#ul_li li").removeClass("on");
            $(this).addClass("on");
            $("#"+v).show();
        });
    });

    function getCode(){
        var mobile = $("#mobile").val();
        if(mobile){
            $.post("{:U('Login/getMobileCode')}",{'mobile':mobile},function(data){
                if(data.status==1){
                    alert(data.msg);
                }else{
                    alert(data.msg);
                }
            });
        }else{
            alert('请输入手机号码')
        }
    }
</script>
<include file="Public:footer" />